
package de.swta.freezay.base;

import de.swta.freezay.FreezaySession;
import de.swta.freezay.Home;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

/**
 * LoginPanel: displayed if the admin is logged out
 *
 * @author Jan Korreck
 * @author Christian Baeumer
 */
public final class LoginPanel extends Panel {

    public LoginPanel(String id) {
        
        super (id);

        /* create a password field */
        final PasswordTextField pwField = new PasswordTextField("loginField",
                new Model(""));

        /* create a form component */
        Form loginForm = new Form("loginForm", new Model("")) {
            @Override
            protected void onSubmit() {
                /* specify the button behaviour */
                ((FreezaySession) getSession()).login(pwField.getInput());
                setResponsePage(Home.class);
            }
         };

         /* add password field to form component */
         loginForm.add(pwField);
         /* add form component to page */
         add(loginForm);
    }
    
}
